//
//  QSAvatorImage.swift
//  chat
//
//  Created by 1 on 2023/4/1.
//

import SwiftUI
import Kingfisher

struct QSAvatorImage: View {
    var string: String
    var body: some View {
        if let url = URL(string: string){
            KFImage(url)
                .resizable()
                .placeholder { progress in
                    Image("avatar")
                        .resizable()
                }
        }else{
            Image("avatar")
                .resizable()
        }
    }
}

struct QSAvatorImage_Previews: PreviewProvider {
    static var previews: some View {
        QSAvatorImage(string: "https://upload.jianshu.io/images/js-qrc.png")
            .frame(width: 100,height: 100)
    }
}
